/*
 * @Author: szx
 * @Date: 2022-03-10 14:44:53
 * @LastEditTime: 2022-03-10 14:56:34
 * @Description:
 * @FilePath: \leetcode\1-99\80\80.js
 */
/**
 * @param {number[]} nums
 * @return {number}
 */
var removeDuplicates = function (nums) {
    let cnt = 1;
    let left = 1;
    for (let i = 1; i < nums.length; i++) {
        if (nums[i] == nums[i - 1]) {
            if (cnt >= 2) continue;
            cnt++;
        } else {
            cnt = 1;
        }
        nums[left++] = nums[i];
    }
    nums.length = left;
    return nums;
};
console.log(removeDuplicates([1, 1, 1, 2, 2, 3]));
console.log(removeDuplicates([1, 1, 1, 2, 2, 3]));
console.log(removeDuplicates([0, 0, 1, 1, 1, 1, 2, 3, 3]));
console.log(removeDuplicates([0, 0, 0, 0, 1, 1]));
